﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Exhibition.Common.CacheManager;
using Exhibition.Common.Helper;
using Exhibition.Dao.ViewModel;

namespace Exhibition.Service
{
    public class ProductClassTree : IDropDownTree
    {
        public Dictionary<string, string> GetChildList(string parentID)
        {
            int uid = 0;
            if (MembershipService.GetUser() != null) {
                uid = MembershipService.GetUser().Id;
            }
            var catcheSiteID = CommonCacheManager.GetCacheData<int>("SiteID" + uid);
           List<ProductClassModel> areas = CenterService.productClassService.GetListByPid(Convert.ToInt32(parentID), catcheSiteID);
            //MembershipService.GetUser().UserSysRight.AreaIds

            if (areas != null && areas.Count > 0)
            {
                Dictionary<string, string> arealist = new Dictionary<string, string>();
                foreach (var tp in areas)
                {
                    arealist.Add(tp.Id.ToString(), tp.ClassName);
                }
                return arealist;
            }
            return null;
        }

        public DropDownTree DropDownTree
        {
            get { return new DropDownTree(this); }
        }

        public void Dispose()
        {

        }
    }
}
